from tkinter import *

root = Tk()

text = Text(root,width=30,height=50)
text.pack()

text.insert(INSERT,'Hello\n')
text.insert(END,'World!')

photo = PhotoImage(file='bg.gif')

def show():
    print("hi...")
    text.image_create(END,image=photo)

b1 = Button(text,text='点击',command=show)
text.window_create(INSERT,window=b1)

mainloop()
